<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>图片管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all" />
    <style>
        #Images li{ width:15.6%; margin:0.5% 0.5%; float: left; overflow:hidden;}
        #Images li img{ width:100%; cursor:pointer; }
        #Images li .operate{ display: block; height: 40px; width:100%; background:#f4f5f9; }
        #Images li .operate .check{ float:left; margin-left:11px; height:18px; padding:11px 0; width:74%; position:relative;}
        #Images li .operate .check .layui-form-checkbox[lay-skin=primary]{ width:100%;}
        #Images li .operate .check .layui-form-checkbox[lay-skin=primary] span{ padding:0 5px 0 25px; width:100%; box-sizing:border-box;}
        #Images li .operate .check .layui-form-checkbox[lay-skin=primary] i{position:absolute; left:0; top:0;}
        #Images li .operate .img_del{ float:right; margin:9px 11px 0 0; font-size: 22px !important; cursor:pointer; }
        #Images li .operate .img_del:hover{ color:#f00; }
        @media screen and (max-width:1050px){#Images li{ width:24%;}}
        @media screen and (max-width: 750px){#Images li{ width:49%;}}
        @media screen and (max-width:432px){#Images li{ width:99%;}}
        .layui-inline{
            max-width: 49%;
        }
        #Images li{
            text-align: center;
        }
        #Images .operate{
            text-align: left;
        }
    </style>
</head>
<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote news_search">
        <div class="layui-inline">
            <input type="checkbox" name="selectAll" id="selectAll" lay-filter="selectAll" lay-skin="primary" title="全选">
        </div>
        <div class="layui-inline">
            <a class="layui-btn layui-btn-sm layui-btn-danger batchDel">批量删除</a>
        </div>
        <div class="layui-inline" style="margin-right: 20px;">
            <a class="layui-btn layui-btn-sm uploadNewImg1">上传新图片</a>
        </div>
        <div class="layui-inline">
            <input type="hidden" id="flag" value="${flag}">
            <select name="" lay-verify="required" lay-filter="pflag">
                <option value="">请选择分类</option>
                <option value="0" ${flag==0?'selected':''}>所有分类</option>
                <option value="1" ${flag==1?'selected':''}>景点详情</option>
                <option value="2" ${flag==2?'selected':''}>学校地图</option>
                <option value="3" ${flag==3?'selected':''}>评论图片</option>
            </select>
        </div>
        <div class="layui-inline" id="homeworklist">
            <input type="hidden" id="_id" value="${id}">
            <select name="" lay-verify="required" lay-search lay-filter="pdate">
                <option value="">请选择关联数据,可搜索</option>
                <option value="0" ${id==0?'selected':''}>所有数据</option>
                #if(flag==1)
                #for(view : list)
                <option value="${view.vId}" ${id==view.vId?'selected':''}>${view.vName}</option>
                #end
                #elseif(flag==2)
                #for(sch : list)
                <option value="${sch.sId}" ${id==sch.sId?'selected':''}>${sch.sName}</option>
                #end
                #end
            </select>
        </div>

    </blockquote>
    <ul class="layer-photos-demo" id="Images">
        <!--<li  style="text-align: center;">-->
            <!--<img src="http://yaokui.ltd:8888/teacherS/iconUpload/2016001_1551885615569.jpg">-->
            <!--<div class="operate" style="text-align: left;">-->
                <!--<div class="check">-->
                    <!--<input type="checkbox" name="belle" lay-filter="choose" lay-skin="primary" title="'+data[i].alt+'">-->
                <!--</div>-->
                <!--<i class="layui-icon img_del">&#xe640;</i>-->
            <!--</div>-->
        <!--</li>-->
    </ul>
</form>
<script>
    var flag = ${flag},
        id = ${id};
</script>
<script type="text/javascript" src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/images.js"></script>
<script type="text/javascript" src="/js/jquery.min.js" ></script>
<script>
    $(".uploadNewImg1").click(function () {
        var index = top.layer.open({
            type: 2
            ,title: '添加图片'
            ,content: 'pictureAdd?flag=${flag}&id=${id}'
            ,maxmin: true
            ,area: ['800px', '700px']
            ,btn: ['确定', '取消']
            ,yes: function(index, layero){
                var iframeWindow = top.window['layui-layer-iframe'+ index]
                    ,submitID = 'LAY-front-submit'
                    ,submit = layero.find('iframe').contents().find('#'+ submitID);

                //监听提交
                iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                    var field = data.field; //获取提交的字段

                    //提交 Ajax 成功后，静态更新表格中的数据
                    $.ajax({
                        url: "addPicture",
                        dataType: "json",
                        type: "post",
                        data: field,
                        success: function (data) {
                            if (data.status == 1) {
                                top.layer.msg('添加成功', {
                                    icon: 1
                                    , time: 1000
                                }, function () {
                                    top.layer.close(index); //关闭弹层
                                    // table.reload('LAY-school-manage'); //数据刷新
                                    window.location.reload();
                                });
                            }
                            else if (data.status == 0) {
                                top.layer.msg('添加失败', {
                                    icon: 0
                                    , time: 1000
                                });
                            }
                        },
                        error: function (result) {
                            console.log(result);
                            alert("系统繁忙！");
                        }
                    });
                });

                submit.trigger('click');
            }
        });
        //如果手机端，全屏显示
        if(window.innerWidth <= 768) {
            top.layui.layer.full(index);
            setTimeout(function () {
                top.layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                    tips: 3
                });
            }, 500)
        }

    });
</script>
</body>
</html>